package com.xs.project.controller;

import com.xs.project.common.Result;
import com.xs.project.pojo.vo.CourseResourceRequest;
import com.xs.project.pojo.vo.XcCourseReq;
import com.xs.project.pojo.vo.XsCourseSubReq;
import com.xs.project.pojo.vo.resp.CourseResourceResp;
import com.xs.project.pojo.vo.resp.CourseSubResp;
import com.xs.project.pojo.vo.resp.XcCourseResp;
import com.xs.project.service.ICourseManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/courseManager")
@Api(tags = "课程管理")
public class CourseManagerController {
    @Resource
    private ICourseManagerService courseManagerService;
    @ApiOperation(value = "列表-课程", notes = "课程资源")
    @PostMapping(value = "/selectCourseList")
    public Result<List<XcCourseResp>> selectCourseList(@RequestBody XcCourseReq request) {
        return courseManagerService.selectCourseList(request);
    }

    @ApiOperation(value = "更新-课程", notes = "课程资源")
    @PostMapping(value = "/updateCourseList")
    public Result<Boolean> updateCourseList(@RequestBody XcCourseResp request) {
        return Result.success(courseManagerService.updateCourseList(request));
    }

    @ApiOperation(value = "新增-课程", notes = "课程资源")
    @PostMapping(value = "/insertCourseList")
    public Result<Boolean> insertCourseList(@RequestBody XcCourseResp request) {
        return Result.success(courseManagerService.insertCourseList(request));
    }


    @ApiOperation(value = "列表-课节", notes = "课程资源")
    @PostMapping(value = "/selectCourseSubList")
    public Result<List<CourseSubResp>> selectCourseSubList(@RequestBody XsCourseSubReq request) {
        return courseManagerService.selectCourseSubList(request);
    }

    @ApiOperation(value = "更新-课节", notes = "课程资源")
    @PostMapping(value = "/updateCourseSubList")
    public Result<Boolean> updateCourseSubList(@RequestBody CourseSubResp request) {
        return Result.success(courseManagerService.updateCourseSubList(request));
    }

    @ApiOperation(value = "新增-课节", notes = "课程资源")
    @PostMapping(value = "/insertCourseSubList")
    public Result<Boolean> insertCourseSubList(@RequestBody CourseSubResp request) {
        return Result.success(courseManagerService.insertCourseSubList(request));
    }

    @ApiOperation(value = "新增-课节", notes = "课程资源")
    @PostMapping(value = "/deleteCourseSubList")
    public Result<Boolean> deleteCourseSubList(@RequestBody CourseSubResp request) {
        return Result.success(courseManagerService.deleteCourseSubList(request.getId()));
    }
}
